﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ZhuanShen.Helpers
{
    public static class HtmlHelpers
    {
        public static MvcHtmlString Img(this HtmlHelper html, string id, string altText, string relativePath)
        {
            //string path = AppManager.Config.CommonConfig.ImagesPathPrefix + relativePath;

            string output = string.Format("<img id=\"{0}\" alt=\"{1}\" title=\"{1}\" src=\"{2}\" />", id, altText, relativePath);

            return MvcHtmlString.Create(output);
        }

        public static MvcHtmlString Script(this HtmlHelper helper, string releaseFile, string debugFile)
        {
            var file = helper.ViewContext.HttpContext.IsDebuggingEnabled ? debugFile : releaseFile;

            var src = string.Format( "~/Content/{0}",file);

            var scriptTag = new TagBuilder("script");
            scriptTag.MergeAttribute("type", "text/javascript");
            scriptTag.MergeAttribute("src", src);
            return MvcHtmlString.Create(scriptTag.ToString(TagRenderMode.Normal));
        }

        public static MvcHtmlString Css(this HtmlHelper helper, string file)
        {
            var src = string.Format("~/Content/{0}", file);

            var linkTag = new TagBuilder("link");
            linkTag.MergeAttribute("type", "text/css");
            linkTag.MergeAttribute("rel", "stylesheet");
            linkTag.MergeAttribute("href", src);

            return MvcHtmlString.Create(linkTag.ToString(TagRenderMode.SelfClosing));
        }
    }
}